from openai import OpenAI
#
deepseek_api_key = "sk-1dd16a258a73428d910d38c782e1c94f"

client = OpenAI(api_key=deepseek_api_key, base_url="https://api.deepseek.com")
#
# response = client.chat.completions.create(
#     model="deepseek-chat",
#     messages=[
#         {"role": "system", "content": "你是一个乐于助人的助手。"},
#         {"role": "user", "content": "你好，我叫武公子"},
#     ],
#     stream=True,
#     max_tokens=1024,
#     temperature=0.7
# )
#
# reasoning_content = ""
# content = ""
# for chunk in response:
#     if chunk.choices[0].delta.reasoning_content:
#         reasoning_content += chunk.choices[0].delta.reasoning_content
#     else:
#         content += chunk.choices[0].delta.content
# print(reasoning_content)
#
# print(content)




# Round 1
messages = [{"role": "user", "content": "9.11 and 9.8, which is greater?"}]
response = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=messages,
    stream=True
)

reasoning_content = ""
content = ""

for chunk in response:
    if chunk.choices[0].delta.reasoning_content:
        reasoning_content += chunk.choices[0].delta.reasoning_content
    else:
        content += chunk.choices[0].delta.content

# Round 2
messages.append({"role": "assistant", "content": content})
messages.append({'role': 'user', 'content': "How many Rs are there in the word 'strawberry'?"})
response = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=messages,
    stream=True
)